package com.exam.api.common.poster;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.ToString;
import org.springframework.util.DigestUtils;

import java.util.List;


/**
 * Poster
 */
@Schema(description = "Poster")
@Data
@ToString
public class Poster {

    /**
     * posterId
     */
    @Schema(description = "posterId")
    @NotEmpty(message = "posterId 不能为空")
    private String posterId;


    @Schema(hidden = true)
    @NotNull(message = "enableZIndex 不能为空")
    private Boolean enableZIndex = false;

    /**
     * 画布宽度
     */
    @Schema(description = "画布宽度")
    @NotNull(message = "画布宽度不能为空")
    private Integer width;

    /**
     * 画布高度
     */
    @Schema(description = "画布高度")
    @NotNull(message = "画布高度不能为空")
    private Integer height;

    /**
     * 背景图片url
     */
    @Schema(description = "背景图片url")
    private String backgroundUrl;

    /**
     * 背景图片备用url
     */
    @Schema(description = "背景图片备用url")
    private String backgroundUrlResUrl;

    /**
     * 画布背景颜色
     */
    @Schema(description = "画布背景颜色")
    private String backgroundColor;

    /**
     * 圆角
     */
    @Schema(description = "圆角")
    private Integer borderRadius;


    /**
     * 高斯模糊
     */
    @Schema(description = "高斯模糊")
    private Integer backgroundBlur;

    /**
     * 文本列表
     */
    @Schema(description = "文本列表")
    private List<Text> texts;

    /**
     * 图片列表
     */
    @Schema(description = "图片列表")
    private List<Image> images;

    /**
     * 矩形元素列表
     */
    @Schema(description = "矩形元素列表")
    private List<Rectangle> rectangles;

    /**
     * 获取key
     *
     * @return String
     */
    @JsonIgnore
    public String key() {
        return DigestUtils.md5DigestAsHex(this.toString().getBytes());
    }
}
